﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using ProjectBase.Core;

namespace $safeprojectname$
{
    public static class Extensions
    {
        // returns the first Error Message or string.Empty
        public static string GetErrorMessage(this IEnumerable<Message> messages)
        {
            if (messages.IsEmpty())
            {
                return string.Empty;
            }
            var error = messages.FirstOrDefault(m => m.Severity.Equals(Severity.Error));
            if (error.IsNull())
            {
                return string.Empty;
            }
            return "Reporter: " + error.Reporter + "; Message: " + error.Text + "; Details: " + error.DebugDetails;
        }
    }
}
